package com.kkyy.findmusic.controller;

import com.kkyy.common.utils.R;
import com.kkyy.findmusic.entity.BannersEntity;
import com.kkyy.findmusic.service.BannersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/findmusic")
public class BannersController {
    @Autowired
    private BannersService bannersService;

    // 查询轮播图(前端)
    @RequestMapping("/banners")
    public R getBanners() {
        List<BannersEntity> banners = bannersService.getBanners();
        return R.ok().put("data", banners);
    }

    // 远程调用查询轮播图(后台)
    @RequestMapping("/banners2")
    public List<BannersEntity> getBanners2() {
        List<BannersEntity> banners = bannersService.getBanners();
        return banners;
    }

    // 远程调用删除轮播图
    @RequestMapping("/delbanner")
    public void delBannerById(@RequestParam("id") Integer id) {
        bannersService.delBannerById(id);
    }

    // 添加轮播图
    @RequestMapping("/addBannerUrl")
    public void addBannerUrl(@RequestParam("url") String url) {
        bannersService.addBannerUrl(url);
    }
}